/*
 * Ngramprob.cpp
 *
 *  Created on: Dec 3, 2014
 *      Author: ale
 */

#include "Ngramprob.h"


Ngramprob::Ngramprob() {
	cantNGramas = 0;
}

Ngramprob::~Ngramprob() {
}

void Ngramprob::agregarNgrama(string ngrama, float prob, float boff){
	pair<float, float> datos;
	datos.first = prob;
	datos.second = boff;

	this->tabla[ngrama] = datos;
	cantNGramas++;
}

float Ngramprob::obtenerProbabilidad(string ngrama){
	google::sparse_hash_map<std::string, pair<double, double> >::iterator i;
	if ((i=tabla.find(ngrama)) == tabla.end())
		return 0;
	else
		return i->second.first;
	return 0;
}

float Ngramprob::obtenerBackOff(string ngrama){
	google::sparse_hash_map<std::string, pair<double, double> >::iterator i;
	if ((i=tabla.find(ngrama)) == tabla.end())
		return 0;
	else
		return i->second.second;
	return 0;
}



